//
//  JSLBillHomeCell.m
//  JingleSpeedLoan
//
//  Created by 宋志彬 on 2018/8/2.
//  Copyright © 2018年 宋质彬. All rights reserved.
//

#import "JSLBillHomeCell.h"

@interface JSLBillHomeCell ()
@property (nonatomic , weak) UILabel *nameLab;
@property (nonatomic , weak) UIImageView *imageV;
@property (nonatomic , weak) UIView *backView;
@end

@implementation JSLBillHomeCell

#pragma mark - init
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = BACKGROUND_COLOR;
        
        [self setUpAllChildView];
        
    }
    return self;
}

-(void)setInfo:(NSDictionary *)info {
    _info = info;
    self.nameLab.text = info[@"name"];
    self.imageV.image = [UIImage imageNamed:info[@"image"]];
}

#pragma mark - 配置视图
- (void)layoutSubviews{
    [super layoutSubviews];
    [self configFrame];
}

- (void)configFrame{
    self.backView.frame = CGRectMake(10*AutoSizeScaleXX, 30*AutoSizeScaleYY, SCREEN_WIDTH - 10*AutoSizeScaleXX *2, 90*AutoSizeScaleYY);
    CGSize nameSize = [self.nameLab.text sizeWithAttributes:@{NSFontAttributeName : self.nameLab.font}];
    self.nameLab.frame = CGRectMake(24*AutoSizeScaleXX, 0, nameSize.width, self.backView.height);
    
    self.imageV.frame = CGRectMake(self.backView.width-35*AutoSizeScaleXX-60*AutoSizeScaleXX, -12*AutoSizeScaleYY, 60*AutoSizeScaleXX, 84*AutoSizeScaleYY);
}
- (void)setUpAllChildView{
    
    self.backView= [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[UIColor whiteColor] superView:self.contentView];
    
    self.nameLab = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"" font:MEDIUM_FONT(16) textColor:[@"#333333" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.backView];
    
    self.imageV = [JSLKitFactory jsl_imageViewWithFrame:CGRectZero imageName:@"" superView:self.backView];
}

#pragma mark - 创建cell
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString * ID = @"JSLBillHomeCell";
    id cell = [tableView dequeueReusableCellWithIdentifier:ID ];
    
    if (cell == nil) {
        cell = [[self alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    
    return cell;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


@end
